<?php
/**
 * Contact Us
 * 
 *  @author Redouane
 *  @since 21/12/2011
 */
class ContactUsForm extends sfForm{
	
	public function configure(){
		/*widgets*/
		$this->widgetSchema['name'] = new sfWidgetFormInputText(array(), array('class' => 'span-8'));
		$this->widgetSchema['email'] = new sfWidgetFormInputText(array(), array('class' => 'span-8'));
		$this->widgetSchema['url'] = new sfWidgetFormInputText(array(), array('class' => 'span-8'));
		$this->widgetSchema['message'] = new sfWidgetFormTextareaTinyMCE(array(), array('class' => 'span-8 contactUsMsg'));
		$this->widgetSchema['captcha'] = new sfWidgetFormReCaptcha(array('public_key' => sfConfig::get('app_recaptcha_publickey')), array('class'=>'captcha'));
		
		//Public Key: 	6LeNq8sSAAAAAKXsbCTyC9Na3myRRANvixnHNNsS 
		//Private Key: 	6LeNq8sSAAAAAPI2YIMtFlD8iUF7PYJ98Fddx8oE
		// www.bay3wachira.com 
		
		
		/* Labels */
		$this->widgetSchema->setLabels(array(
	      	'name'   => 'Nom *',
			'email'  => 'Email *',
			'url'	 => 'Site internet',
			'message' => "Message * +",
	    ));
	    
		/* Validators */
    	$this->validatorSchema['name']  = new sfValidatorString(array('required' => true));
    	$this->validatorSchema['email'] = new sfValidatorEmail(array('required' => true));   
    	$this->validatorSchema['message'] = new sfValidatorString(array('required' => true, 'max_length' => 256 ));
    	$this->validatorSchema['url'] = new sfValidatorUrl(array('required' => false));
    	$this->validatorSchema['captcha'] = new sfValidatorReCaptcha(array('private_key' => sfConfig::get('app_recaptcha_privatekey')), array('captcha' => 'captcha invalide (%error%).'));
    	
    	/* Schema */
		$this->validatorSchema['email']->setMessage('required', 'Veuillez renseigner l\'Email');
		$this->validatorSchema['email']->setMessage('invalid', 'Email invalide');
	    $this->validatorSchema['name']->setMessage('required', 'Veuillez renseigner votre Nom');
	    $this->validatorSchema['message']->setMessage('required', 'Veuillez renseigner votre message');
	    $this->validatorSchema['message']->setMessage('max_length', 'Votre message est trop long');
	    $this->validatorSchema['url']->setMessage('invalid', 'Url invalide');
	    $this->validatorSchema['captcha']->setMessage('required', 'Veuillez renseigner le captcha');
    	
	    $this->widgetSchema->setNameFormat('contactus[%s]');
		$this->widgetSchema->setFormFormatterName('div');
		$this->widgetSchema->getFormFormatter()->setTranslationCatalogue('front');
    	
	}
	
	
}